<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title>谷歌脚本测试</title>
</head>
<body>
<div id="j_Container" eid="container">
	<div id="j_ContainerHead" eid="head">
		<h2>头部</h2>
	</div>
	<div id="j_ContainerBody" eid="body">
		<ul id="j_ContainerUl" eid="ul">
			<li id="j_ContainerLi1" eid="li1"><a href="http://www.baidu.com/" target="_blank" title="新闻一">新闻一</a></li>
			<li id="j_ContainerLi2" eid="li2"><a href="http://www.163.com/" target="_blank" title="新闻二">新闻二</a></li>
			<li id="j_ContainerLi3" eid="li3"><a href="http://www.sina.com/" target="_blank" title="新闻三">新闻三</a></li>
			<li id="j_ContainerLi4" eid="li4"><a href="http://www.sohu.com/" target="_blank" title="新闻四">新闻四</a></li>
			<li id="j_ContainerLi5" eid="li5"><a href="http://www.qq.com/" target="_blank" title="新闻五">新闻五</a></li>
		</ul>
	</div>
	<div id="j_ContainerFoot" eid="foot">
		<span>底部</span>
	</div>
</div>
<div id="j_Container2">
	<div id="j_ContainerHead2">
		<h2>头部</h2>
	</div>
	<div id="j_ContainerBody2">
		<ul id="j_ContainerUl2">
			<li id="j_ContainerLi11"><a href="http://www.baidu.com/" target="_blank" title="新闻一">新闻一</a></li>
			<li id="j_ContainerLi21"><a href="http://www.163.com/" target="_blank" title="新闻二">新闻二</a></li>
			<li id="j_ContainerLi31"><a href="http://www.sina.com/" target="_blank" title="新闻三">新闻三</a></li>
			<li id="j_ContainerLi41"><a href="http://www.sohu.com/" target="_blank" title="新闻四">新闻四</a></li>
			<li id="j_ContainerLi51"><a href="http://www.qq.com/" target="_blank" title="新闻五">新闻五</a></li>
		</ul>
	</div>
	<div id="j_ContainerFoot2">
		<span>底部</span>
	</div>
</div>
<script type="text/javascript">
	var goo = {
		kEI: "google"
	};


	var getEI = function(el) {
		/**
		 * for循环中中间的判断条件为false时自动退出循环
		 */

		/**
		** 方法一
		for (var eid; el && (!el.getAttribute || !(eid = el.getAttribute("eid"))); ) {
			el = el.parentNode;
		}
		**/

		/**
		** 方法二
		for (var eid; el; ) {
			if (!el.getAttribute) {
				el = el.parentNode;
			} else {
				eid = el.getAttribute("eid");
				if (!eid) {
					el = el.parentNode;
				} else {
					break;
				}
			}
		}
		**/

		/**
		** 方法三
		**/
		var eid;
		for (; ; ) {
			if (el) {
				if (!el.getAttribute) {
					el = el.parentNode;
				} else {
					eid = el.getAttribute("eid");
					if (!eid) {
						el = el.parentNode;
					} else {
						break;
					}
				}
			} else {
				break;
			}
		}

		return eid || goo.kEI;
	};
	
	var domUl = document.getElementById("j_ContainerUl");
	console.log("domEl: ", getEI(domUl));
</script>
</body>
</html>